/**
 * Created by LXhan on 2017/11/20.
 */
var activebuildingID = '';//选中楼宇ID
layui.use(['jquery', 'table', 'laydate', 'form', 'layer', 'element'], function (){
    element = layui.element;
    activebuildingID = QueryUtils.GetQueryString('activebuildingID');
    var data = {};
    data.buildingId=activebuildingID;

   /* table.render({
        elem: '#sellCardId'
        , url: '/billController/listSellCards'
        , where: data
        , cols: [[
            {checkbox: true, LAY_CHECKED: true} //默认全选
            , {field: 'ROOM_NUM', event: 'setSign', title: '项目编号', width: 160, sort: 'true', templet: '#weishouTpl'}
            ,{field: 'BYNAME', event: 'setSign', title: '别名', width: 120, sort: 'true'}
            , {field: 'COMPANY_NAME', event: 'setSign', title: '承租方', width: 120, sort: 'true'}
            , {field: 'PARK_CARD', event: 'setSign', title: '张数', width: 120, sort: 'true'}
            , {field: 'TOTAL_PRICE', event: 'setSign', title: '金额', width: 120, align: 'right',sort: 'true'}
            , {field: 'ALLOT_BILL', event: 'setSign', title: '收款类型', width: 120, sort: 'true'}
            , {field: 'CREATE_DATE', event: 'setSign', title: '操作时间', width: 120, sort: 'true'}
            , {field: 'CREATE_ID', event: 'setSign', title: '操作人', width: 120}
            , {fixed: 'right', width: 200, align: 'center', title: '操作', toolbar: '#dclbar'}

        ]]
        , id: 'szlbID'
        , page: true
        , height: 'full-180'
        , limit: '10'
    });*/


    //自用账单    查看
    table.on('tool(sellCard)', function (obj) {
        debugger
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值
        var nametype = data.BILL_NAME;
        var type;
        //自用账单标识问题 为了查看不显示 实际收款
        var hideShoukuan = "1";
        var payment_logo; // 1  支出  0 收费
        if(!data.TOTAL_PRICE.indexOf("-")){//应付账单标识
            payment_logo=1;
        }

        if(sellType=="baoyue"){
            hideShoukuan="0";
        }else if(sellType=="maika"){
            hideShoukuan="1";
        }else{
            hideShoukuan="2";
        }
        if (layEvent === 'detail' && sellType=="baoyue") {
            parent.layer.open({
                zIndex: 1000,
                type: 2,    //弹出类型
                title: '查看账单',   //标题
                closeBtn: 1,    //显示关闭按钮
                shade: [0.3],   //遮罩透明度
                area: ['900px', '90%'],  //打开窗口的宽高
                time: 0,    //几秒后自动关闭，默认0时不关闭
                anim: 1,    //动画效果
                resize: false,  //设置成不允许拉伸
                content: '../../../webhtml/depot/depot_byCard_check.html?payment_logo='+escape(payment_logo)+'&hd=' + escape(hideShoukuan) + '&&type=' + escape(nametype) + '&BILL_ID=' + data.ID + ''  //iframe的url
            });
        }
        if (layEvent === 'detail' && sellType=="maika") {
            parent.layer.open({
                zIndex: 1000,
                type: 2,    //弹出类型
                title: '查看账单',   //标题
                closeBtn: 1,    //显示关闭按钮
                shade: [0.3],   //遮罩透明度
                area: ['900px', '90%'],  //打开窗口的宽高
                time: 0,    //几秒后自动关闭，默认0时不关闭
                anim: 1,    //动画效果
                resize: false,  //设置成不允许拉伸
                content: '../../../webhtml/depot/depot_check.html?payment_logo='+escape(payment_logo)+'&hd=' + escape(hideShoukuan) + '&&type=' + escape(nametype) + '&BILL_ID=' + data.ID + ''  //iframe的url
            });
        }
        if (layEvent === 'detail' && sellType=="linshi") {
            parent.layer.open({
                zIndex: 1000,
                type: 2,    //弹出类型
                title: '查看账单',   //标题
                closeBtn: 1,    //显示关闭按钮
                shade: [0.3],   //遮罩透明度
                area: ['900px', '90%'],  //打开窗口的宽高
                time: 0,    //几秒后自动关闭，默认0时不关闭
                anim: 1,    //动画效果
                resize: false,  //设置成不允许拉伸
                content: '../../../webhtml/depot/depot_interim_check.html?payment_logo='+escape(payment_logo)+'&hd=' + escape(hideShoukuan) + '&&type=' + escape(nametype) + '&BILL_ID=' + data.ID + ''  //iframe的url
            });
        }
    });


    });
